package pl.pawluk.inz.dto;

import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: mandp
 * Date: 19.04.13
 * Time: 22:09
 * To change this template use File | Settings | File Templates.
 */
public class UserDTO extends BaseDTO {
    private String email;
    private Boolean active;
    private String firstName;
    private String middleName;
    private String surname;
    private String password;
    private String address;
    private String city;
    private String zipCode;
    private final Set<GroupDTO> groups = new HashSet<GroupDTO>();
    private Set<String> authorities = new HashSet<String>();
    private final Set<CourseDTO> courses = new HashSet<CourseDTO>();

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getMiddleName() {
        return middleName;
    }

    public void setMiddleName(String middleName) {
        this.middleName = middleName;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getZipCode() {
        return zipCode;
    }

    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    public Set<GroupDTO> getGroups() {
        return groups;
    }

    public Set<String> getAuthorities() {
        return authorities;
    }

    public void setAuthorities(Set<String> authorities) {
        this.authorities = authorities;
    }

    public Set<CourseDTO> getCourses(){
        return this.courses;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof UserDTO)) return false;

        UserDTO userDTO = (UserDTO) o;

        if (active != null ? !active.equals(userDTO.active) : userDTO.active != null) return false;
        if (address != null ? !address.equals(userDTO.address) : userDTO.address != null) return false;
        if (authorities != null ? !authorities.equals(userDTO.authorities) : userDTO.authorities != null) return false;
        if (city != null ? !city.equals(userDTO.city) : userDTO.city != null) return false;
        if (courses != null ? !courses.equals(userDTO.courses) : userDTO.courses != null) return false;
        if (email != null ? !email.equals(userDTO.email) : userDTO.email != null) return false;
        if (firstName != null ? !firstName.equals(userDTO.firstName) : userDTO.firstName != null) return false;
        if (groups != null ? !groups.equals(userDTO.groups) : userDTO.groups != null) return false;
        if (middleName != null ? !middleName.equals(userDTO.middleName) : userDTO.middleName != null) return false;
        if (password != null ? !password.equals(userDTO.password) : userDTO.password != null) return false;
        if (surname != null ? !surname.equals(userDTO.surname) : userDTO.surname != null) return false;
        if (zipCode != null ? !zipCode.equals(userDTO.zipCode) : userDTO.zipCode != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = email != null ? email.hashCode() : 0;
        result = 31 * result + (active != null ? active.hashCode() : 0);
        result = 31 * result + (firstName != null ? firstName.hashCode() : 0);
        result = 31 * result + (middleName != null ? middleName.hashCode() : 0);
        result = 31 * result + (surname != null ? surname.hashCode() : 0);
        result = 31 * result + (password != null ? password.hashCode() : 0);
        result = 31 * result + (address != null ? address.hashCode() : 0);
        result = 31 * result + (city != null ? city.hashCode() : 0);
        result = 31 * result + (zipCode != null ? zipCode.hashCode() : 0);
        result = 31 * result + (groups != null ? groups.hashCode() : 0);
        result = 31 * result + (authorities != null ? authorities.hashCode() : 0);
        result = 31 * result + (courses != null ? courses.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "UserDTO{" +
                "email='" + email + '\'' +
                ", active=" + active +
                ", firstName='" + firstName + '\'' +
                ", middleName='" + middleName + '\'' +
                ", surname='" + surname + '\'' +
                ", password='" + password + '\'' +
                ", address='" + address + '\'' +
                ", city='" + city + '\'' +
                ", zipCode='" + zipCode + '\'' +
                ", groups=" + groups +
                ", authorities=" + authorities +
                ", courses=" + courses +
                '}';
    }
}
